package file;

import java.io.File;
import java.io.IOException;

public class DeleteFile {
    public static void main(String[] args) throws IOException {
        File file = new File("test.txt");

        for (int i = 0; i < 100; i++) {
            if (file.exists()) {
                System.out.println("文件存在");
                file.delete();
                System.out.println("文件已删除");
            } else {
                System.out.println("文件不存在");
                file.createNewFile();
                System.out.println("文件已创建");
            }
        }
    }
}
